<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">点击发送ajax请求-请求B域名</button>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
    // 点击 btn 按钮发送ajax请求
    let url = 'http://localhost:8081'; // B域名接口地址
    $('#btn').click(function () {
        $.ajax({
            url,
            type: 'get',
            dataType: 'json',
            success: function (res) {
                console.log(res);
            }
        })
    })

</script>

</html>